<?php

declare(ENCODING = 'UTF-8');

/*                                                                        *
 * This script is part of the TYPO3 project - inspiring people to share!  *
 *                                                                        *
 * TYPO3 is free software; you can redistribute it and/or modify it under *
 * the terms of the GNU General Public License version 2 as published by  *
 * the Free Software Foundation.                                          *
 *                                                                        *
 * This script is distributed in the hope that it will be useful, but     *
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *	
 * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General      *
 * Public License for more details.                                       *
 *                                                                        */	

/**
 * @package auxo
 * @subpackage AOP
 * @version $Id$
 */

/**	
 * The AOP Component Configuration PostProcessor
 * 
 * This post processor is executed after a component definition is loaded. If an class is 
 * adviced here the classname is replaced with its proxy classname.
 *	
 * @package auxo
 * @subpackage AOP
 * @version $Id$	
 * @copyright Copyright belongs to the respective authors
 * @author AHN
 * @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2
 */
class tx_auxo_AOPComponentConfigurationPostProcessor implements tx_auxo_ComponentConfigurationPostProcessorInterface {
	
	/**
	 * AOP Manager
	 *
	 * @var tx_auxo_AOPManager
	 */
	private $AOPManager;
	
	/**
	 * Creates a new post processor 
	 *
	 * @param tx_auxo_AOPManager $AOPmanager
	 */
	public function __construct(tx_auxo_AOPManager $AOPmanager) {
		$this->AOPManager = $AOPManager;
	}

	/**
	 * Method that is called after a definition has been parsed and before building a component
	 * 
	 * It replaces the classname with a proxy classname if this class has been adviced by 
	 * the AOP framework.
	 *
	 * @param tx_auxo_ComponentDefinition $definition a component definition
	 * @return tx_auxo_ComponentDefinition $definition a changed or wrapped or whatsoever definition
	 */
	public function PostProcessDefinition(tx_auxo_ComponentDefinition $definition) {
		if ($this->AOPManager->processClass($definition->getClass())) {
			$definition->setClass($this->AOPManager->getMetadata($classname)->get('targetClass'));
		}
		return $definition;
	}
}
?>